<script type="text/javascript">
    $("#license_mess_modal").parents(".modal-dialog").css("min-width", 577);
    var enable_submit = true;
    function submit_license_create() {
        var modal_license = $("#license_mess_modal");
        var company_name = modal_license.find("#lic_company_name");
        var capacity = modal_license.find("#lic_capacity");
        var contact = modal_license.find("#lic_contact");
        var telephone = modal_license.find("#lic_telephone");
        var mail = modal_license.find("#lic_mail");
        var objs = [
            { 'el': company_name, 'regs': [
                {'regexp': /^[\u4e00-\u9fa5a-zA-Z0-9()]+$/i, 'text': '应由汉字、字母、数字和括号组成。'}
            ], 'text': '单位名称不能为空。'},
            //{ 'el': capacity, 'regs': [
            //    {'regexp': /^[0-9]+$/i, 'text': '配额必须为大于0的整数。'}
            //], 'text': '申请容量不能为空。'},
            { 'el': contact, 'regs': [
                {'regexp': /^[\u4e00-\u9fa5a-zA-Z]+$/i, 'text': '应由汉字和字母组成。'}
            ], 'text': '联系人不能为空。'},
            { 'el': telephone,'regs':[
                {'regexp': [/^1[3|4|5|7|8][0-9]{9}$/i, /^0\d{2,3}-?\d{7,8}$/], 'text': '电话号码格式不正确。'}
            ], 'text': '电话不能为空。'},
            { 'el': mail,'regs': [
                {'regexp': /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/i, 'text': '邮箱地址格式不正确。'}
            ], 'text': '邮箱不能为空。'}
        ];
        var result = checkEnableSubmit(objs);
        var jqtip = $('.error-tip');
        jqtip.css({
            'top': '-9999px',
            'left': '-9999px'
        });
        modal_license.find('input').css({
            'border': '1px solid #d8dce5'
        });
        if(result.enableSubmit === false) {
            var $el = result.el;
            var $parent = $el.parent();
            var top = $parent[0].offsetTop;
            var left = $parent[0].offsetLeft + 120;
            var jqtip = $('.error-tip');
            jqtip.find('p').text(result.text);
            jqtip.css({
                'top': top + 'px',
                'left': left + 'px'
            });
            $el.css({
                'border': '1px solid #fa575f'
            });
            return ;
        }

        var post_data = {
            "lic_company_name": company_name.val(),
            "lic_capacity": capacity.val(),
            "lic_contact": contact.val(),
            "lic_telephone": telephone.val(),
            "lic_mail": mail.val()
        };
        var $submitBtn = $('.modal-footer').find('.butn-sub');
        $submitBtn.html('<i class="fa fa-spinner fa-spin" style="margin:3px 6px;"></i>');
    	$.post('/license/create/message', post_data, function(data){
                if (data.reply.is_success){
                	if (enable_submit) {
                	    angular.element('#license_open_button').scope().close("/license/create/message");
                	    angular.element('#license_open_button').scope().open("/license/create/upload");
                	}
                }else{
                    error = data.reply.error;
    	     }
    	});
    }
    function license_message_ok() {
        angular.element('#license_open_button').scope().close("/license/create/message");
        angular.element('#license_open_button').scope().open("/license/create/home");
    }
</script>
<div class="modal-header">
    <h3>激活注册</h3>
    <i id="close_icon" ng-click="cancel()" class="fa fa-times"></i>
</div>
<div class="modal-body modal-body-height license_mess_body" id="license_mess_modal">
    <div class="license_box" style="position: relative">
        <div id="license_open_button" ng-controller="LicenseModalCtrl"></div>
        <span class="license_head_title">申请信息</span><span class="license_head_cpy">请填写您的申请信息</span>
        <table class="license_table">
            <tr>
                <td>
                    <label>单位名称<a class="inportant_log">*</a></label>
                </td>
                <td>
                    <input type="text" id="lic_company_name">
                </td>
            </tr>
            <tr style="display:none">
                <td>
                    <label>申请容量<a class="inportant_log">*</a></label>
                </td>
                <td>
                    <input type="text" id="lic_capacity">
                </td>
            </tr>
            <tr>
                <td>
                    <label>联系人<a class="inportant_log">*</a></label>
                </td>
                <td>
                    <input type="text" id="lic_contact">
                </td>
            </tr>
            <tr>
                <td>
                    <label>电话<a class="inportant_log">*</a></label>
                </td>
                <td>
                    <input type="text" id="lic_telephone">
                </td>
            </tr>
            <tr>
                <td>
                    <label>邮箱<a class="inportant_log">*</a></label>
                </td>
                <td>
                    <input type="text" id="lic_mail">
                </td>
            </tr>
        </table>
        <div class="error-tip">
            <p></p>
            <span></span>
        </div>
    </div>
</div>
<div class="modal-footer license_footer">
    <button class="button button_gray butn-sub" ng-click="customer_ok()">提交</button>
    <button class="button button_gray butn-back" ng-click="go_license_home()">返回</button>
</div>
